package com.macro.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.macro.enums.AppHttpCodeEnum;
import com.macro.mapper.UiBrandMapper;
import com.macro.pojos.dto.ResponseResult;
import com.macro.pojos.pojo.UiBrand;
import com.macro.service.UiBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class UiBrandServiceImpl implements UiBrandService {

    @Autowired
    UiBrandMapper uiBrandMapper;

    @Override
    public ResponseResult queryBrand() {
        LambdaQueryWrapper<UiBrand> lambdaQueryWrapper = new LambdaQueryWrapper();
        lambdaQueryWrapper.eq(UiBrand::getIsDelete,false);
        List<UiBrand> uiBrands = uiBrandMapper.selectList(lambdaQueryWrapper);
        if (CollectionUtils.isEmpty(uiBrands)){
            return ResponseResult.errorResult(AppHttpCodeEnum.DATA_NOT_EXIST);
        }
        return ResponseResult.okResult(uiBrands);
    }
}
